package com.control;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.RequestMapping;
import com.alibaba.fastjson2.JSON;
/**
 * 文件控制器 demo
 * @author 37798955@qq.com
 *
 */
public class FileControl {
////限制 交给ngnix
	// 测试传入与传出参数
	@RequestMapping("/f/test")
	public void test(HttpServletRequest request, HttpServletResponse response) throws IOException {
		// @RequestParam Map<String, String> R 其他参数
		// @RequestPart("file") MultipartFile file 单个文件
		// @RequestParam("idPic") MultipartFile[] mufiles 多个文件
		response.setContentType("application/json; charset=utf-8");
		PrintWriter out = response.getWriter();
		Map<String, String> mm = new HashMap<String, String>();
		mm.put("cc", "val");
		out.write(JSON.toJSONString(mm));
		out.flush();
		out.close();
	}

	/*
	 * 文件列表
	 * 
	 * @RequestMapping("/f/getall/{scope}")
	 * 
	 * @ResponseBody public List<Map<String, Object>> getfilelist(HttpServletRequest
	 * req, HttpServletResponse res,
	 * 
	 * @PathVariable String scope) { MySession tk = My.getSession(req);
	 * 
	 * //return SqlOfFile.getFiles(tk.getUserId(), scope, "2"); }
	 * 
	 * @RequestMapping("/f/remove/{fileid}")
	 * 
	 * @ResponseBody public Map<String, Object> removefile(HttpServletRequest req,
	 * HttpServletResponse res,
	 * 
	 * @PathVariable String fileid) { MySession tk = My.getSession(req); Content ct
	 * = new Content(); if (tk.getRoleid() != M.ROLE_管理员) { ct.setCode(0,
	 * "你没有权限删除该文件"); return ct.get(); } try { UserFileComp.delFile(fileid);
	 * ct.setCode(1, "该文件已经删除"); } catch (Exception e) { ct.setCode(0, "该文件删除异常" +
	 * e.getMessage()); } return ct.get(); }
	 */
}
